import React, { Component } from 'react';
import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native";
import { GLOBAL } from '../../../../config/global';
const scale = GLOBAL.SCALE;
export class QuantityAdressCpt extends Component {
	constructor(props) {
		super(props);
		let { addressIndex } = this.props || {};
		this.state = {
			addressIndex
		}
	}

	componentWillMount () {

	}

	_selectAddressFn = (index) => {
		let { callBackAdress } = this.props || {};
		this.setState({
			addressIndex: index
		}, () => {
			callBackAdress && callBackAdress(index);
		})
	}



	render () {
		let { data } = this.props || {};
		let { addressIndex } = this.state;
		let imgOff = require('../../../../imgs/global/finishIcon.png');
		let imgOn = require('../../../../imgs/global/option.png');
		return (
			<View>
				{
					data && data.map((item, index) => {
						return (
							<TouchableOpacity onPress={() => { this._selectAddressFn(index) }} key={index} style={styles.tipAddressBox}>
								<Image source={addressIndex == index ? imgOff : imgOn} style={styles.tipAddressImg} />
								<Text style={[styles.tipAddressText]}>{item.addressName}</Text>
							</TouchableOpacity>
						)
					})
				}
			</View>
		)
	}
}
const styles = StyleSheet.create({
	tipAddressBox: {
		flexDirection: 'row',
		marginBottom: 15 * scale
	},
	tipAddressText: {
		fontSize: 13 * scale,
	},
	tipAddressTextActive: {
		fontWeight: 'bold'
	},
	tipAddressImg: {
		marginRight: 5 * scale,
		width: 15 * scale,
		height: 15 * scale
	}
})